<?php
/**
 * Controller
 *
 * @author $AUTHOR$
 * @since $DATE$
 * @version $ID$
 */
defined('ANTFW_ROOT') || die('Access denied');

class antController {

    public static $config = NULL;
    public static $view = NULL;

    public final function antController() {

    }


    protected final function assign($key, $value) {
        $this->initView();
        self::$view->assign($key, $value);
    }


    /**
     * Display template
     *
     * @access protected
     * @param string $template
     * @return string
     */
    protected final function display($template = NULL) {
        if (NULL === $template)
            $template = CONTROLLER. '/'. ACTION;

        $this->initView();
        self::$view->display($template);
    }


    /**
     * Fetch template
     *
     * @access public
     * @param string $template
     * @return string
     */
    public final function fetch($template) {
        $this->initView();
        return self::$view->fetch($template);
    }


    /**
     * initialize view
     *
     * @access private
     * @return void
     */
    private function initView() {
        if (NULL === self::$view) {
            require ANTFW_ROOT. 'view.class.php'; 
            self::$view = new view;
        }
    }
}
